Don't paint in the trailing end of a wrapped line when the selection
authorOwen Taylor <otaylor@redhat.com>
Tue, 30 Nov 2004 21:33:36 +0000 (21:33 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 30 Nov 2004 21:33:36 +0000 (21:33 +0000)
Tue Nov 30 16:25:29 2004  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktextdisplay.c (render_para): Don't paint in the
        trailing end of a wrapped line when the selection
        starts after the line. (#159984, Matthias Clasen)

        * gtk/gtktextdisplay.c (gtk_text_layout_draw): pass in byte_count + 1
        for selection_end index when the selection end is past the end of the
        line so that render_para() can distinguish it from selection-end
        *at* the end of the line. Fixes newlines not being selected.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextdisplay.c

index a606a0ef8df79f40a639eda6b066695a40335ae7..fba1c60449b973a79f9c8c52b33c5254e6ef9f14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Nov 30 16:25:29 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextdisplay.c (render_para): Don't paint in the
+       trailing end of a wrapped line when the selection 
+       starts after the line. (#159984, Matthias Clasen)
+
+       * gtk/gtktextdisplay.c (gtk_text_layout_draw): pass in byte_count + 1 
+       for selection_end index when the selection end is past the end of the 
+       line so that render_para() can distinguish it from selection-end
+       *at* the end of the line. Fixes newlines not being selected.
+
 2004-11-30  James M. Cape  <jcape@ignore-your.tv>
 
        * gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_get_active)
index a606a0ef8df79f40a639eda6b066695a40335ae7..fba1c60449b973a79f9c8c52b33c5254e6ef9f14 100644 (file)
@@ -1,3 +1,14 @@
+Tue Nov 30 16:25:29 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextdisplay.c (render_para): Don't paint in the
+       trailing end of a wrapped line when the selection 
+       starts after the line. (#159984, Matthias Clasen)
+
+       * gtk/gtktextdisplay.c (gtk_text_layout_draw): pass in byte_count + 1 
+       for selection_end index when the selection end is past the end of the 
+       line so that render_para() can distinguish it from selection-end
+       *at* the end of the line. Fixes newlines not being selected.
+
 2004-11-30  James M. Cape  <jcape@ignore-your.tv>
 
        * gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_get_active)
index a606a0ef8df79f40a639eda6b066695a40335ae7..fba1c60449b973a79f9c8c52b33c5254e6ef9f14 100644 (file)
@@ -1,3 +1,14 @@
+Tue Nov 30 16:25:29 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextdisplay.c (render_para): Don't paint in the
+       trailing end of a wrapped line when the selection 
+       starts after the line. (#159984, Matthias Clasen)
+
+       * gtk/gtktextdisplay.c (gtk_text_layout_draw): pass in byte_count + 1 
+       for selection_end index when the selection end is past the end of the 
+       line so that render_para() can distinguish it from selection-end
+       *at* the end of the line. Fixes newlines not being selected.
+
 2004-11-30  James M. Cape  <jcape@ignore-your.tv>
 
        * gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_get_active)
index a606a0ef8df79f40a639eda6b066695a40335ae7..fba1c60449b973a79f9c8c52b33c5254e6ef9f14 100644 (file)
@@ -1,3 +1,14 @@
+Tue Nov 30 16:25:29 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextdisplay.c (render_para): Don't paint in the
+       trailing end of a wrapped line when the selection 
+       starts after the line. (#159984, Matthias Clasen)
+
+       * gtk/gtktextdisplay.c (gtk_text_layout_draw): pass in byte_count + 1 
+       for selection_end index when the selection end is past the end of the 
+       line so that render_para() can distinguish it from selection-end
+       *at* the end of the line. Fixes newlines not being selected.
+
 2004-11-30  James M. Cape  <jcape@ignore-your.tv>
 
        * gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_get_active)
index 4b621b4315d9e1ee79d1f384a71a692117596218..2a3e4853a038c81c13b9062e8065cbd58fe52fde 100644 (file)
@@ -538,8 +538,13 @@ render_para (GtkTextRenderer    *text_renderer,
                                           PANGO_SCALE * x + line_rect.x,
                                           PANGO_SCALE * y + baseline);
 
-          if (selection_start_index <= byte_offset + line->length &&
-              selection_end_index > byte_offset) /* Some selected */
+         /* Check if some part of the line is selected; the newline
+          * that is after line->length for the last line of the
+          * paragraph counts as part of the line for this
+          */
+          if ((selection_start_index < byte_offset + line->length ||
+              (selection_start_index == byte_offset + line->length && pango_layout_iter_at_last_line (iter))) &&
+             selection_end_index > byte_offset)
             {
               GdkRegion *clip_region = get_selected_clip (text_renderer, layout, line,
                                                           x + line_display->x_offset,
@@ -754,7 +759,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
                   if (gtk_text_iter_compare (&selection_end, &line_end) <= 0)
                     selection_end_index = gtk_text_iter_get_visible_line_index (&selection_end);
                   else
-                    selection_end_index = MAX(byte_count, 1);
+                    selection_end_index = byte_count + 1; /* + 1 to flag past-the-end */
                 }
             }